#define _CRT_SECURE_NO_WARNINGS 0
#include"RBTree.h"
#include"myset.h"
#include"mymap.h"
#include<map>
void test01()
{
	egghead::set<int>myset;
	//int arr[] = { 16, 3, 7, 11, 9, 26, 18, 14, 15 };
	int arr[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14 };
	for (auto num : arr)
		myset.insert(num);
	myset.inorder();
}

void test02()
{
	struct GETVAL { const int& operator()(const int& val) { return val; } };
	RBTree<int, int, GETVAL>t;
	int arr[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14 };
	for (auto num : arr)
		t.insert(num);
	t.inorder();
}

void test03()
{
	egghead::map<int,int>mymap;
	int arr[] = { 16, 3, 7, 11, 9, 26, 18, 14, 15 };
	//int arr[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14 };
	for (auto num : arr)
		mymap.insert({ num, num});
	mymap.inorder();
}

void test04()
{
	srand(time(0));
	const int N = 1000;
	egghead::map<int, int>mymap;
	int begin1 = clock();
	for (int i = 0; i < N; i++)
		mymap.insert({ i + rand(),i });
	int end1 = clock();
	mymap.inorder();
	if (mymap.checktree())
		cout << "----Tree Correct----" << endl;
	else
		cout << "----Tree Error----" << endl;
	cout << "Tree size:" << mymap.size() << endl;
}

void test05()
{
	srand(time(0));
	const int N = 10;
	egghead::map<int, int>mymap;
	int begin1 = clock();
	for (int i = 0; i < N; i++)
		mymap.insert({ i + rand() % N,i });
	int end1 = clock();
	//mymap.inorder();
	auto begin = mymap.begin();
	while (begin != mymap.end())
	{
		cout << begin->first << ' ';
		++begin;
	}
	cout << endl;
	mymap[16] = 16;
	mymap[17] = 16;
	mymap[100] = 16;
	mymap[0] = 16;
	for (auto& e : mymap)
		cout << e.first << ':' << e.second << ' ';
	cout << endl;
	if (mymap.checktree())
		cout << "----Tree Correct----" << endl;
	else
		cout << "----Tree Error----" << endl;
	cout << "Tree size:" << mymap.size() << endl;
}



void test06()
{
	srand(time(0));
	const int N = 10;
	egghead::set<int>myset;
	int begin1 = clock();
	for (int i = 0; i < N; i++)
		myset.insert({ i + rand() % N });
	int end1 = clock();
	//mymap.inorder();
	auto begin = myset.begin();
	while (begin != myset.end())
	{
		cout << *begin << ' ';
		++begin;
	}
	cout << endl;
	for (auto& e : myset)
		cout << e << ' ';
	cout << endl;
	if (myset.checktree())
		cout << "----Tree Correct----" << endl;
	else
		cout << "----Tree Error----" << endl;
	cout << "Tree size:" << myset.size() << endl;
}


int main()
{
	//test01();
	//test02();
	//test03();
	//test04();
	//test05();
	//test06();
	

}